package com.lizhen.j2eepattern.frontcontrollerpattern;

public class FrontController {
    private Dispatcher dispatcher = new Dispatcher();

    public FrontController() {
    }

    private boolean isAuthenticUser() {
        System.out.println("User is authenticated successfully.");
        return true;
    }

    private void trackRequest(String request) {
        System.out.println("Page requested: " + request);
    }

    public void dispatchRequest(String request) {
        this.trackRequest(request);
        if (this.isAuthenticUser()) {
            this.dispatcher.dispatch(request);
        }

    }
}
